package msu.ml.data.level2;

import java.util.*;

/**
 * A Volume Coverage Pattern determines the number
 * of scans in a volume scan, the angles of those
 * scans, and the type of data collected by each
 * scan.
 *
 * @author Reginald M Mead
 * @version 1.0
 */
public abstract class VolumeCoveragePatternBase implements IVolumeCoveragePattern
{
	protected float [] angles;
	protected float [] scanAngles;

   public float [] getAngles()
   {
      return angles;
   }
	
	/**
	 * Get the angle of the scan(sweep) at
	 * the specified index.
	 *
	 * @param scanIndex index of scan
	 * @return angle of scan
	 */
	public float getAngle(int scanIndex)
	{
		return scanAngles[scanIndex];
	}

	/**
	 * Get the indexes of all scans with the
	 * specified elevation angle.
	 *
	 * @param angle angle of scans
	 * @return an ArrayList of indexes
	 */
	public ArrayList<Integer> getIndexesForAngle(float angle)
	{
		ArrayList<Integer> result = new ArrayList<Integer>();
		for(int i = 0; i < scanAngles.length; i++)
		{
			if(scanAngles[i] == angle)
				result.add(new Integer(i+1));
		}
		return result;
	}

	/**
	 * Get the number of different elevation angles
	 * in this pattern.
	 *
	 * @return the number of different elevation angles
	 */
	public int getNumAngles()
	{
		return angles.length;
	}

	/**
	 * Get the number of scans in this pattern.
	 *
	 * @return the number of scans
	 */
	public int getNumScans()
	{
		return scanAngles.length;
	}

	/**
	 * Get the total scan time for one volume
	 * scan using this pattern.
	 *
	 * @return the total time for a volume scan
	 */
	public abstract int getTotalScanTime();

	/**
	 * Returns true if the scan at the specified
	 * angle contains doppler information.
	 *
	 * @param scanIndex index of scan
	 * @return true if scan contains doppler data
	 */
	public abstract boolean isDopplerScan(int scanIndex);

	/**
	 * Returns true if the scan at the specified
	 * angle contains reflectivity information.
	 *
	 * @param scanIndex index of scan
	 * @return true if scan contains reflectivity data
	 */
	public abstract boolean isReflectivityScan(int scanIndex);

	/**
	 * Set the angles to the given angle data
	 *
	 * @param angleData angles for this pattern.
	 */
	protected void initializeAngles(float [] angleData)
	{
		this.angles = new float[angleData.length];
		for(int i = 0; i < angleData.length; i++)
			this.angles[i] = angleData[i];
	}

	/**
	 * Set the scan angles for this pattern.
	 *
	 * @param scanAngleData scan angles
	 */
	protected void initializeScanAngles(float [] scanAngleData)
	{
		this.scanAngles = new float[scanAngleData.length];
		for(int i = 0; i < scanAngleData.length; i++)
			this.scanAngles[i] = scanAngleData[i];
	}

}
